package adfc2.core;

import java.util.logging.Logger;

/**
 * Задача --- длительный процесс, состоящий из множества действий
 */
public abstract class Task {
    protected static final Logger logger = Logger.getLogger(Task.class.getName());
    public final Creature actor;
    public boolean completed = false;
    public boolean failed = false;

    protected final World world() {
        return World.world();
    }

    public Task(Creature actor) {
        this.actor = actor;
    }

    /**
     * Запрос следующего действия
     */
    public abstract Action nextAction();

    protected void completed() {
        logger.fine(actor + " completed " + toString());
        completed = true;
    }

    public final void start() {
        logger.fine(actor + " started " + toString());
        actor.startTask(this);
    }

    public void cancel() {
        logger.fine("Canceled " + toString());
        // :(  okay
    }

    public abstract String shortName();

    protected void failed() {
        failed = true;
    }
}
